package com.bupt.liutong.admin.migrate.quartz;

import java.util.Date;

import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import com.bupt.liutong.admin.groupon.dao.GrouponDao;
import com.bupt.liutong.util.DateUtils;

public class OldGrouponBo {

	@Autowired
	private GrouponDao grouponDao;

	public void execute() {
		Date thisMonth = DateUtils.thisMonth(DateUtils.getCurDate());
		String tablePostfix = DateUtils.getYear(thisMonth)
				+ DateUtils.getMonth(thisMonth);
		grouponDao.createBackupTable(tablePostfix);
		grouponDao.backupGroupon(tablePostfix);
		grouponDao.deleteOrigGroupon(tablePostfix);
		grouponDao.backupFuzzyTimeGroupon(tablePostfix);
		grouponDao.deleteOrigFuzzyTimeGroupon(tablePostfix);
	}
	
	public static void main(String[] args) throws JobExecutionException{
		FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(
				new String[] {
						"D:\\javadev\\MyEclipse 6.6\\workspace\\groupon-info-download\\WebRoot\\WEB-INF\\spring\\spring.xml",
						"D:\\javadev\\MyEclipse 6.6\\workspace\\groupon-info-download\\WebRoot\\WEB-INF\\spring\\spring-admin.xml" });
		OldGrouponBo oldGrouponBo = (OldGrouponBo) context.getBean("oldGrouponBo");
		oldGrouponBo.execute();
	}

	public void setGrouponDao(GrouponDao grouponDao) {
		this.grouponDao = grouponDao;
	}
}
